package com.daocao.hua.fragment;

import android.graphics.Color;
import android.graphics.drawable.GradientDrawable;
import android.os.Bundle;
import android.text.Spanned;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.daocao.hua.R;
import com.daocao.hua.model.V3HomeIndexModel;
import com.daocao.hua.util.DisplayUtil;
import com.daocao.hua.util.Spans;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;

/**
 * Created by xsooy-pc on 18-6-12.
 */

public class V3HomeBottomOneSecFragment extends BaseFragment {

    Unbinder unbinder;
    @BindView(R.id.txt_content)
    TextView txtContent;
    @BindView(R.id.layout_total)
    LinearLayout layoutTotal;
    private V3HomeIndexModel.DataBean.OverdueNotice data;
    private int x20;
    private int poi;

    @Override
    protected int setLayoutId() {
        return R.layout.fragment_v3_home_bottom_one_sec;
    }

    public void setData(V3HomeIndexModel.DataBean.OverdueNotice data, int poi) {
        this.data = data;
        this.poi = poi;
    }

    @Override
    protected void initView() {
        x20 = getResources().getDimensionPixelSize(R.dimen.x20);
        if (data != null) {
            Spanned info = Spans.with(this).font(data.real_name + "  " + data.sex, x20, 0xffffffff).
                    font("  借款" + data.borrow_amount + "元\n逾期" + data.overdue_days + "天\n身份证:" + data.idno + "\n处理方式:" + data.handle, x20, 0x80ffffff).build();
            txtContent.setText(info);

        }
        if (poi % 3 == 0) {
            layoutTotal.setBackgroundResource(R.mipmap.img_overdue_one);
        } else if (poi % 3 == 1) {
            layoutTotal.setBackgroundResource(R.mipmap.img_overdue_two);
        } else if (poi % 3 == 2) {
            layoutTotal.setBackgroundResource(R.mipmap.img_overdue_three);
        }
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        // TODO: inflate a fragment view
        View rootView = super.onCreateView(inflater, container, savedInstanceState);
        unbinder = ButterKnife.bind(this, rootView);
        return rootView;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }
}
